<!DOCTYPE html>
<html>
  <head>
    <title>Socializer</title>
    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag "socializer/application", media: "all" %>
  </head>
  <body data-controller="<%= controller_name %>" data-action="<%= action_name %>" data-locale="<%= I18n.locale %>" >

    <% if signed_in? %>
      <!-- TODO: Consider creating a header partial -->
      <% cache do  %>
        <header role="banner">
          <%= render "socializer/shared/topbar" %>
          <%= yield :toolbar %>
        </header>
      <% end %>
    <% end %>

    <div id="content" class="container">
      <%= render "socializer/shared/flash" %>

      <div class="row">

      <% if signed_in? %>
        <aside class="stream-column" role="complementary">
          <%= render "socializer/shared/main_navigation" %>
        </aside>

        <%# if params[:controller] == "socializer/activities" && (params[:provider] == "groups" || params[:provider] =="circles" || params[:provider].nil?) %>
        <% if controller_path == "socializer/activities" ||
              controller_name == "circles" || controller_path == "socializer/circles/activities" ||
              controller_name == "groups" || controller_path == "socializer/groups/activities" ||
              controller_path.include?("people")
        %>

        <main class="page-content" role="main">
          <%= yield %>
        </main>

        <aside class="contextual-column" role="complementary">
          <% if controller_name == "circles" || controller_path == "socializer/circles/activities" %>
            <%= render "socializer/circles/sidebar", circle: local_assigns[:circle], title: local_assigns[:title] if local_assigns[:circle] %>
          <% elsif controller_name == "groups" || controller_path == "socializer/groups/activities" %>
            <%= render "socializer/groups/sidebar", group: local_assigns[:group], title: local_assigns[:title] if local_assigns[:group] %>
          <% elsif controller_path.include?("people") %>
            <%= render "socializer/people/sidebar", person: local_assigns[:person] if local_assigns[:person] %>
          <% elsif controller_path == "socializer/activities" %>
            <%= render "socializer/activities/sidebar" %>
          <% end %>
        </aside>

        <% else %>

        <main class="page-content" role="main">
          <%= yield %>
        </main>

        <% end %>

      <% else %>
        <main class="page-content" role="main">
          <%= render "socializer/people/login" %>
        </main>
      <% end %>

      </div><!-- /.row -->
    </div><!-- /.container -->

    <!-- TODO: Consider creating a footer partial -->
    <% cache do %>
      <footer role="contentinfo">
        <div class="container">
          <div class="row">
          </div><!-- /.row -->
        </div><!-- /.container -->
      </footer>
    <% end %>

    <%= javascript_include_tag "socializer/application" %>
  </body>
</html>
